﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using contactus.Models;
using System.Net.Mail;
using System.Configuration;

namespace contactus.Controllers
{
    public class HomeController : Controller
    {
        // 
        // POST: /ContactUs/ 

        [HttpPost]
        public ActionResult Index(MessageInfo msgInfo)
        {
            new SmtpClient().SendAsync(new MailMessage(
               msgInfo.Email,
               ConfigurationManager.AppSettings["DestinationEmail"],
               msgInfo.Subject,
               string.Format(@"
FullName: {0}
PhoneNumber: {1}
Subject: {2}
Comments:
{3}
", msgInfo.FullName, msgInfo.PhoneNumber, msgInfo.Subject, msgInfo.Comments)), null);
            
            return Redirect(msgInfo.Redirect);
        }

#if DEBUG
        public ActionResult Browse()
        {
            return View();
        }
#endif
    }
}
